Repository navigation
Conversation
hvitved
force-pushed
the
unified/type-inference-constructors
branch
2 times, most recently
from
October 10, 2026 07:22
e5f4c43 to
909aa94
Compare
hvitved
force-pushed
the
unified/type-inference-constructors
branch
from
October 19, 2026 07:54
8102a8e to
80c4bfb
Compare
hvitved
force-pushed
the
unified/type-inference-constructors
branch
from
October 19, 2026 13:51
ecd7a28 to
843c4c4
Compare
hvitved
force-pushed
the
unified/type-inference-constructors
branch
from
October 19, 2026 14:16
843c4c4 to
4e6a1ef
Compare
hvitved
force-pushed
the
unified/type-inference-constructors
branch
from
October 19, 2026 19:51
7a3d1be to
1c20541
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Constructor inference loses contextual argument types and can produce incorrect inherited type mappings and superclass results.
4 open issues
What changed in this PR
Improves constructor-call type inference in Unified, particularly for inherited Swift initializers.
Changes:
- Models constructors using receiver types.
- Extends shared contextual inference support.
- Adds inherited-constructor tests and updates expectations.
| File | Description |
|---|---|
| unified/ql/test/library-tests/type-inference/type-inference.expected | Updates generated inference expectations. |
| unified/ql/test/library-tests/type-inference/lub.swift | Updates an inline expected initializer target. |
| unified/ql/test/library-tests/type-inference/constructors.swift | Adds inherited and generic constructor cases. |
| unified/ql/lib/codeql/unified/internal/typeinference/TypeMention.qll | Excludes enum cases from resolved types. |
| unified/ql/lib/codeql/unified/internal/typeinference/TypeInference.qll | Adds receiver-based constructor inference. |
| unified/ql/lib/codeql/unified/internal/ExprPositions.qll | Excludes enum cases from type contexts. |
| shared/typeinference/codeql/typeinference/internal/TypeInference.qll | Extracts reusable contextual typing logic and adds an inference hook. |
Review effort: Max
Comment on lines
+667
to
+668
| cd = i.getTargetImpl(_).asCallable() and | ||
| result = inferType(i.getArgument(0), path) |
| or | ||
| // inherited constructor | ||
| exists(TypeAbstraction abs, TypeMention constraint, TypeParameter tp | | ||
| BaseTypes::rootTypesSatisfaction(_, TClassLikeDeclarationType(declType), abs, _, |
| n = | ||
| any(TypeMention tm | | ||
| tm = getConstructionReceiver(_) and | ||
| result = tm.getTypeAt(path) |
| super.init() // $ target=C3.init | ||
| } | ||
|
|
||
| override convenience init() { |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.